package com.example.springboot.controller;

import com.example.springboot.common.Result;
import com.example.springboot.entity.Discussion;
import com.example.springboot.entity.DiscussionAndUser;
import com.example.springboot.service.IDiscussionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/discussion")
public class DiscussionController {
    @Autowired
    IDiscussionService discussionService;

    @GetMapping("/getTree")
    public Result getTree(@RequestParam(value = "discussionType")Integer discussionType, @RequestParam(value = "positionId")Integer positionId){
        List<DiscussionAndUser> discussion = discussionService.getTree(discussionType,positionId);
        return Result.success(discussion);
    }

    @PostMapping("/addDiscussion")
    public Result addDiscussion(@RequestBody Discussion discussion){
        discussionService.addDiscussion(discussion);
        return Result.success();
    }
}
